package 代码随想录.贪心;

public class a55跳跃游戏 {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {2, 3, 1, 1, 4};
        System.out.println(solution.canJump(nums));
    }

    static class Solution {
        public boolean canJump(int[] nums) {
            if (nums.length <= 1) return true;
            int cover = 0;
            for (int i = 0; i <= cover; i++) {
                cover = Math.max(cover, i + nums[i]);
                if (cover >= nums.length - 1) return true;
            }
            return false;
        }
    }
}
